home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer.codewarrior,comp.lang.c++
- Path: info.physics.utoronto.ca!news
- From: Andrew Datars <datars@tiger.physics.utoronto.ca>
- Subject: Re: using a template parameter as a qualifier -- legal or not?
- Message-ID: <3117C2B0.41C6@tiger.physics.utoronto.ca>
- Nntp-Posting-Host: husky.physics.utoronto.ca
- Sender: news@info.physics.utoronto.ca (System Administrator)
- Mime-Version: 1.0
- X-Mailer: Mozilla 2.0b6a (X11; I; IRIX64 6.0.1 IP26)
- Content-Type: text/plain; charset=us-ascii
- Organization: Dept. of Physics, Univ. of Toronto
- Date: Tue, 6 Feb 1996 21:05:52 GMT
- References: <rshapiro-0602961258310001@esb.bbn.com>
- Content-Transfer-Encoding: 7bit
-
- R Shapiro wrote:
- >
- > I'd like to use the formal argument to a template as the qualifier of a
- > qualified typename within the template. This doesn't work in CodeWarrior
- > 8, it does work in VC++ 4.0, and I can't tell from ARM whether or not it
- > *should* work.
- >
- > Here's a more specific example:
- >
- > template <class OBJECT>
- > class OrderedCollection {
- > typedef void (OBJECT::*memberMapper)(void);
- > .
- > .
- > .
- > };
- >
- > I would like the typedef 'memberMapper' to refer to pointers to member
- > functions (of no arguments and returning no value) of whatever class is
- > specified in a given instantiation of the template.
- >
- > For instance, if X and Y are classes, I would expect memberMapper in
- > OrderedCollection<X> to be:
- >
- > void (X::*memberMapper)(void)
- >
- > and memberMapper in OrderedCollection<Y> to be:
- >
- > void (Y::*memberMapper)(void)
- >
- > Should this work or not? If not, why not? If so -- this is a bug in CW8.
- >
- > --
- > rs/rshapiro@bbn.com
-
- I have in my code something like this ...
-
- typedef double (INTERPOLATE_DOS::*TInterpolateFunction)(double);
-
- where INTERPOLATE_DOS is a parameter to the template.
-
- However, I would not be that surprised if CodeWarrior doesn't
- work with it. I have a little anecdote. I started trying
- to use pointers to member functions of a parametrized class
- about 3 years ago. At the time few compilers really had templates
- working very well. With a little snippet of code I could break
- many compilers. I can still use this to break certain
- compilers in certain instances (where the pointer to member function
- is to an overloaded function). I have not used CodeWarrior. So
- I can't really comment on your question directly. I know that
- for most compilers the above DOES work. But I have had the technique
- actually cause the SGI compiler to crash, as well as evoke
- all kinds of wacky error messages from cfront, and g++, and Borland
- C++ 4.5.
-
- Hope that helps.
-
-
- Andrew
- --
- Andrew Datars (datars@tiger.physics.utoronto.ca)
- Quantum Transport/General Computer Helper phone:(416)978-6185
- Dept. of Physics, Univ. of Toronto fax: (416)978-2537
-